﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CCWin;
namespace weiqijiance.工位配置
{
    public partial class BRsetting : CCSkinMain
    {
        public BRsetting()
        {
            InitializeComponent();
        }

        private void BRsetting_Load(object sender, EventArgs e)
        {
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\安综检仪表配置.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            textBox1.Text = objini.ReadValue("制动", "电机超时时间").Trim();
            textBox2.Text = objini.ReadValue("制动", "电机启动时差").Trim();
            textBox3.Text = objini.ReadValue("制动", "滑移参数").Trim();
            textBox4.Text = objini.ReadValue("制动", "基准值").Trim();
            textBox5.Text = objini.ReadValue("制动", "举升时间").Trim();
            textBox6.Text = objini.ReadValue("制动", "信息显示时间").Trim();
            textBox7.Text = objini.ReadValue("制动", "预警系数").Trim();
            check_zuo.Checked = (objini.ReadValue("制动", "第三滚筒左边有效").Trim() == "1") ? true : false;
            check_you.Checked = (objini.ReadValue("制动", "第三滚筒右边有效").Trim() == "1") ? true : false;
            check_jssb.Checked = (objini.ReadValue("制动", "检测线结束设备").Trim() == "1") ? true : false;
            check_cdjc.Checked = (objini.ReadValue("制动", "轴重制动重叠检测").Trim() == "1") ? true : false;
            check_jtlh.Checked = (objini.ReadValue("制动", "轮荷采用静态轮荷").Trim() == "1") ? true : false;
            check_zdfj.Checked = (objini.ReadValue("制动", "自动复检制动").Trim() == "1") ? true : false;
            chbdzcbph.Checked = (objini.ReadValue("制动", "多轴车使用静态轴荷计算不平衡率").Trim() == "1") ? true : false;
            che_ddzj.Checked = objini.ReadValue("制动", "只检单独综检").Trim().Contains("是") ? true : false;

            txtsjcs.Text = objini.ReadValue("制动", "时间参数").Trim();
            txtjgcs.Text = objini.ReadValue("制动", "间隔参数").Trim();
            txtjzsj.Text = objini.ReadValue("制动", "加载台升降时间").Trim();

            check_zzlv.Checked = (objini.ReadValue("制动", "综检需要阻滞率").Trim().Contains("是")) ? true : false;
            cb_qhsxt.Checked = (objini.ReadValue("制动", "前后摄像启用").Trim().Contains("是")) ? true : false;
            cb_roundsw.Checked = (objini.ReadValue("制动", "四舍五入计算不平衡").Trim().Contains("是")) ? true : false;

            textBox8.Text = objini.ReadValue("制动", "IP").Trim();
            textBox9.Text = objini.ReadValue("制动", "Port").Trim();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\安综检仪表配置.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            objini.Writue("制动", "电机超时时间", textBox1.Text);
            objini.Writue("制动", "电机启动时差", textBox2.Text);
            objini.Writue("制动", "滑移参数", textBox3.Text);
            objini.Writue("制动", "基准值", textBox4.Text);
            objini.Writue("制动", "举升时间", textBox5.Text);
            objini.Writue("制动", "信息显示时间", textBox6.Text);
            objini.Writue("制动", "IP", textBox8.Text);
            objini.Writue("制动", "Port", textBox9.Text);

            objini.Writue("制动", "第三滚筒左边有效", check_zuo.Checked ? "1" : "0");
            objini.Writue("制动", "第三滚筒右边有效", check_you.Checked ? "1" : "0");
            objini.Writue("制动", "检测线结束设备", check_jssb.Checked ? "1" : "0");
            objini.Writue("制动", "轴重制动重叠检测", check_cdjc.Checked ? "1" : "0");
            objini.Writue("制动", "轮荷采用静态轮荷", check_jtlh.Checked ? "1" : "0");
            objini.Writue("制动", "自动复检制动", check_zdfj.Checked ? "1" : "0");
           
            objini.Writue("制动", "多轴车使用静态轴荷计算不平衡率", chbdzcbph.Checked ? "1" : "0");

            objini.Writue("制动", "时间参数", txtsjcs.Text);
            objini.Writue("制动", "间隔参数", txtjgcs.Text);
            objini.Writue("制动", "加载台升降时间", txtjzsj.Text);

            objini.Writue("制动", "只检单独综检", che_ddzj.Checked ? "是" : "否");
            objini.Writue("制动", "综检需要阻滞率", check_zzlv.Checked ? "是" : "否");
            objini.Writue("制动", "预警系数", textBox7.Text);
            objini.Writue("制动", "前后摄像启用", cb_qhsxt.Checked ? "是" : "否");
            objini.Writue("制动", "四舍五入计算不平衡", cb_roundsw.Checked ? "是" : "否");
            MessageBox.Show("完成");
            基类窗体.UploadAndDownload fupload = new 基类窗体.UploadAndDownload();
            objini.Ini(System.Windows.Forms.Application.StartupPath + "\\系统信息.ini");
            string sjcxname = objini.ReadValue("系统信息", "检测线名称");
            string sgongweiname = objini.ReadValue("系统信息", "检测工位名称");
            fupload.upload(sjcxname, sgongweiname, "安综检仪表配置.ini");
        }

        private void BRsetting_MouseDoubleClick(object sender, MouseEventArgs e)
        {
        }

        private void BRsetting_MouseDown(object sender, MouseEventArgs e)
        {
        }

        private void label7_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (bkeydown)
            {
                lbljgcs.Visible = true;
                lbljgcsmr.Visible = true;
                lblsjcs.Visible = true;
                lblsjcsmr.Visible = true;
                txtjgcs.Visible = true;
                txtsjcs.Visible = true;
            }

        }
        bool bkeydown = false;
        private void BRsetting_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F8)
            {
                bkeydown = true;
            }

        }

        private void BRsetting_KeyUp(object sender, KeyEventArgs e)
        {
            bkeydown = false;
        }
    }
}
